//
//  HJDWeightViewController.m
//  JYHospital
//
//  Created by 胡金东 on 16/5/13.
//  Copyright © 2016年 胡金东. All rights reserved.
//

#import "HJDWeightViewController.h"
#import "WareViewController.h"
#import "HJDWeightGuideViewController.h"

@interface HJDWeightViewController ()

@property (nonatomic,strong) UIButton * lblshow;


@end

@implementation HJDWeightViewController


-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
//    self.navigationItem.rightBarButtonItem = NO;
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self setUpText];
    
    [self setUpBtn];
    self.title = @"称体重";
    [self.navigationController.navigationBar setTitleTextAttributes:
     @{NSFontAttributeName:[UIFont systemFontOfSize:19],
       NSForegroundColorAttributeName:[UIColor getColorWithHexNumber:@"848484"]}];

    
    self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(shareBtnClick) image:@"矢量智能对象" HighImage:nil];
    
//    UIButton *shareBtn = [[UIButton alloc]init];
//    [shareBtn setBackgroundImage:[UIImage imageNamed:@"矢量智能对象"] forState:UIControlStateNormal];
//    self.navigationItem.rightBarButtonItem =
    //添加手势
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewTapped:)];
    tap.cancelsTouchesInView = NO;
    [self.view addGestureRecognizer:tap];
    
}

//隐藏键盘
-(void)viewTapped:(UITapGestureRecognizer*)tap
{
    
    [self.view endEditing:YES];
    
}


-(void)setUpText
{
    CGFloat lblX = 0 ;
    CGFloat lblY = HJDNavigHeight;
    CGFloat lblW = HJDWidth;
    CGFloat lblH = 40;
    UILabel *lbl = [[UILabel alloc]initWithFrame:CGRectMake(lblX, lblY, lblW, lblH)];
    lbl.backgroundColor = [UIColor getColorWithHexNumber:@"CFCFCF"];
    lbl.text = @"  点击数一数今日胎动数，为您预测宝宝健康值";
    lbl.font = [UIFont systemFontOfSize:14];
    lbl.textColor = [UIColor lightGrayColor];
    [self.view addSubview:lbl];
    
    
    CGFloat heightX = HJDHorizontalMargin ;
    CGFloat heightY = CGRectGetMaxY(lbl.frame)+5;
    CGFloat heightW = HJDWidth - HJDHorizontalMargin-HJDHorizontalMargin*2;
    CGFloat heightH = 40;
    UITextField  *heightField = [[UITextField alloc]initWithFrame:CGRectMake(heightX, heightY, heightW, heightH)];
    heightField.clearButtonMode = UITextFieldViewModeAlways;
    heightField.keyboardType = UIKeyboardTypeNumberPad;

    heightField.leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 70,heightH )];
    heightField.leftViewMode = UITextFieldViewModeAlways;
    UILabel *heightLbl = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 70,heightH )];
    heightLbl.text = @"输入身高";
    heightLbl.textColor = [UIColor getColorWithHexNumber:@"323232"];
    [heightField.leftView addSubview:heightLbl];
    [self.view addSubview:heightField];
    
    CGFloat hLblX = HJDWidth - HJDHorizontalMargin *2;
    CGFloat hLblY = heightY;
    CGFloat hLblW = 40;
    CGFloat hLblH = heightH;
    UILabel *hLbl = [[UILabel alloc]initWithFrame:CGRectMake(hLblX, hLblY, hLblW, hLblH)];
    hLbl.text = @"cm";
    [self.view addSubview:hLbl];

    //    横线
    CGFloat viewX = HJDHorizontalMargin ;
    CGFloat viewY = CGRectGetMaxY(heightField.frame);
    CGFloat viewW = HJDWidth - HJDHorizontalMargin ;
    CGFloat viewH = 1;
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(viewX, viewY, viewW, viewH)];
    view.backgroundColor = [UIColor getColorWithHexNumber:@"CFCFCF"];
    [self.view addSubview:view];
    
    CGFloat massX = HJDHorizontalMargin ;
    CGFloat massY = CGRectGetMaxY(view.frame)+5;
    CGFloat massW = HJDWidth - HJDHorizontalMargin-HJDHorizontalMargin*2;
    CGFloat massH = 40;
    UITextField  *masstextField = [[UITextField alloc]initWithFrame:CGRectMake(massX, massY,massW, massH)];
   
    masstextField.keyboardType = UIKeyboardTypeNumberPad;
    masstextField.clearButtonMode = UITextFieldViewModeAlways;
    
    masstextField.leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 70,massH )];
    masstextField.leftViewMode = UITextFieldViewModeAlways;
    UILabel *masstextLbl = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 70,massH )];
    masstextLbl.text = @"孕前体重";
    masstextLbl.textColor = [UIColor getColorWithHexNumber:@"323232"];
    [masstextField.leftView addSubview:masstextLbl];
    
    [self.view addSubview:masstextField];
    
    CGFloat mLblX = HJDWidth - HJDHorizontalMargin *2 +5;
    CGFloat mLblY = massY;
    CGFloat mLblW = 40;
    CGFloat mLblH = massH;
    UILabel *mLbl = [[UILabel alloc]initWithFrame:CGRectMake(mLblX, mLblY, mLblW, mLblH)];
    mLbl.text = @"kg";
    [self.view addSubview:mLbl];
    //    横线
    CGFloat nowmassviewX = HJDHorizontalMargin ;
    CGFloat nowmassviewY = CGRectGetMaxY(masstextField.frame);
    CGFloat nowmassviewW = HJDWidth - HJDHorizontalMargin ;
    CGFloat nowmassviewH = 1;
    UIView *nowmassview = [[UIView alloc]initWithFrame:CGRectMake(nowmassviewX, nowmassviewY, nowmassviewW, nowmassviewH)];
    nowmassview.backgroundColor = [UIColor getColorWithHexNumber:@"CFCFCF"];
    [self.view addSubview:nowmassview];
    CGFloat X = HJDHorizontalMargin ;
    CGFloat Y = CGRectGetMaxY(nowmassview.frame) + 5;
    CGFloat W = HJDWidth - HJDHorizontalMargin -HJDHorizontalMargin*2;
    CGFloat H = 40;
    UITextField  *nowmasstextField = [[UITextField alloc]initWithFrame:CGRectMake(X, Y, W, H)];
    nowmasstextField.keyboardType = UIKeyboardTypeNumberPad;
    nowmasstextField.clearButtonMode = UITextFieldViewModeAlways;
    nowmasstextField.leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 70,H )];
    nowmasstextField.leftViewMode = UITextFieldViewModeAlways;
    UILabel *nowmassLbl = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 70,H )];
    nowmassLbl.text = @"孕前体重";
    nowmassLbl.textColor = [UIColor getColorWithHexNumber:@"323232"];
    [nowmasstextField.leftView addSubview:nowmassLbl];

    [self.view addSubview:nowmasstextField];
    
    
    CGFloat nLblX = HJDWidth - HJDHorizontalMargin *2 + 5;
    CGFloat nLblY = Y;
    CGFloat nLblW = 40;
    CGFloat nLblH = H;
    UILabel *nLbl = [[UILabel alloc]initWithFrame:CGRectMake(nLblX, nLblY, nLblW, nLblH)];
    nLbl.text = @"kg";
    [self.view addSubview:nLbl];

     //    横线
    CGFloat massviewX = HJDHorizontalMargin ;
    CGFloat massviewY = CGRectGetMaxY(nowmasstextField.frame);
    CGFloat massviewW = HJDWidth - HJDHorizontalMargin ;
    CGFloat massviewH = 1;
    UIView *massview = [[UIView alloc]initWithFrame:CGRectMake(massviewX, massviewY, massviewW, massviewH)];
    massview.backgroundColor = [UIColor getColorWithHexNumber:@"CFCFCF"];
    [self.view addSubview:massview];
    
    CGFloat imageVX = HJDWidth  -105;
    CGFloat imageVY = CGRectGetMaxY(nowmasstextField.frame)+HJDVerticalMargin;
    CGFloat imageVW = 30;
    CGFloat imageVH = 20;
    UIImageView *imageV = [[UIImageView alloc]initWithFrame:CGRectMake(imageVX, imageVY, imageVW, imageVH)];
    imageV.image = [UIImage imageNamed:@"-0"];
    [self.view addSubview:imageV];
    
    CGFloat lblshowX = HJDWidth  -80;
    CGFloat lblshowY = CGRectGetMaxY(nowmasstextField.frame)+HJDVerticalMargin;
    CGFloat lblshowW = 70;
    CGFloat lblshowH = 20;
    self.lblshow = [[UIButton alloc]initWithFrame:CGRectMake(lblshowX, lblshowY, lblshowW, lblshowH)];
    [self.lblshow setTitle:@"体重指南" forState:UIControlStateNormal];
    [self.lblshow setTitleColor:[UIColor getColorWithHexNumber:@"FF92A2"] forState:UIControlStateNormal];
    self.lblshow.titleLabel.font = [UIFont systemFontOfSize:14];
    [self.lblshow addTarget:self action:@selector(weightBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.lblshow];
    
    
}

-(void)setUpBtn
{
    CGFloat submitbtnX = 40;
    CGFloat submitbtnY = CGRectGetMaxY(self.lblshow.frame) + HJDVerticalMargin * 2;
    CGFloat submitbtnW = HJDWidth - 40 * 2;
    CGFloat submitbtnH = 60;
    
    UIButton *submitbtn = [[UIButton alloc]initWithFrame:CGRectMake(submitbtnX, submitbtnY,submitbtnW, submitbtnH)];
    [submitbtn setTitle:@"提交" forState:UIControlStateNormal];
    //    要失效
    //    seebtn.font = [UIFont systemFontOfSize:19];
    submitbtn.titleLabel.font = [UIFont systemFontOfSize:25];
    [submitbtn setRadius:10 borderWith:0 borderColor:nil];
    [submitbtn setBackgroundColor:[UIColor getColorWithHexNumber:@"5CC6AC"]];
    [submitbtn addTarget:self action:@selector(submitbtnClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:submitbtn];
    
}

-(void)shareBtnClick
{
    NSLog(@"分享");
}

-(void)weightBtnClick{
    HJDWeightGuideViewController *guide = [[HJDWeightGuideViewController alloc]init];
    [self.navigationController pushViewController:guide animated:YES];
}

-(void)submitbtnClick
{
    WareViewController * ware = [[WareViewController alloc]init];
    [self.navigationController pushViewController:ware animated:YES];
}

@end
